const fs = window.require('fs');
const mime = require('mime');

export const electronReadFile = async filepath => {
  const stat = fs.statSync(filepath);
  if (stat.isFile()) {
    const fileName = filepath.replace(/^.*[/\\]/, '');
    const data = fs.readFileSync(filepath);
    return new File([data], fileName, {
      type: mime.getType(filepath),
    });
  }
};
